#pragma once

#include <qframe.h>
#include "ui_ChannelWidget.h"
#include <qgraphicsscene.h>
#include <qgraphicsproxywidget.h>
#include "Config.h"
#include "Channels.h"
#include <qtimer.h>

class ChannelWidget : public QFrame
{
	Q_OBJECT

public:
	ChannelWidget(const ChannelCreateInfo* i);
	~ChannelWidget();

	void mousePressEvent(QMouseEvent* event) override;
	void mouseMoveEvent(QMouseEvent* event) override;
	void mouseReleaseEvent(QMouseEvent* event) override;
	void mouseDoubleClickEvent(QMouseEvent* event) override;
	void contextMenuEvent(QContextMenuEvent* event) override;
public slots:
	void slot_check_state(CHANNEL_STATE st);
	void slot_closed();
	//void slot_timer_check_state();
signals:
	void sig_closed(ChannelWidget*);
public:
	void start_server(const ChannelCreateInfo* i);
	void stop_server();
private:
	Ui::ChannelWidget ui;
	Qt::MouseButton current_btn;
	QPoint current_mouse_point;
	ChannelCreateInfo info;
	Channel* channel;
	CHANNEL_STATE ui_state;
	//QTimer check_state_timer;
private:
	void connect_action();
};
